package edu.bupt.c1array;

public class T15RotateImage {
    public void rotate(int[][] matrix) {
        int n = matrix.length;
        if (matrix.length < 2){
            return;
        }

        // 1- 斜翻转
        for (int i=0;i<n;i++){
            for (int j=i+1;j<n;j++){
                int temp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = temp;
            }
        }
        // 2- 左右翻转
        for (int i=0;i<n; i++){
            for (int j=0;j<n/2;j++){

                int temp = matrix[i][j];
                matrix[i][j] = matrix[i][n-1-j];
                matrix[i][n-j-1] = temp;
            }
        }

    }
}
